home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / Developer Essentials Jul 90 / Programming / MPW Interfaces & Libraries 3.1 / AIncludes / FixMath.a < prev    next >
Encoding:
Text File  |  1989-10-13  |  3.3 KB  |  128 lines  |  [TEXT/MPS ]

  1. ; Version: 1.03
  2. ; Created: Tuesday, August 2, 1988 at 9:25:03 PM
  3.  
  4. ; File: FixMath.a
  5. ;
  6. ; Copyright Apple Computer, Inc. 1984-1988
  7. ; All Rights Reserved
  8. ;
  9.  
  10.  
  11. ; These calls support three types of fixed point numbers, each 32 bits long.
  12. ; The bits are interpreted as shown. The '-' represents the sign bit.
  13. ;
  14. ; Type <---------Integer Portion--------> <-------Fractional Portion------>
  15. ;LongInt -xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx.
  16. ;Fixed -xxxxxxx xxxxxxxx.xxxxxxxx xxxxxxxx
  17. ;Fract -x.xxxxxxxx xxxxxxxx xxxxxxxx xxxxxx
  18. ;
  19. ; Type LongInt can represent integers between +/-2147483647. Type Fixed can
  20. ; represent fractional quantities between +/-32768, with about 5 digits of
  21. ; accuracy. Type Fract can represent fractional quantities between +/-2 with
  22. ; about 9 digits of accuracy. These numeric representations are useful for
  23. ; applications that do not require the accuracy of the floating point routines,
  24. ; and which need to run as fast as possible. The Graf3D three dimensional
  25. ; graphics package resides on top of these routines. Although FixMul is in the
  26. ; file ToolTraps, it is shown below to show how it handles different types.
  27. ; Additional fixed point routines are described in the Inside Macintosh chapter,
  28. ; “Toolbox Utilities.”
  29.  
  30. ; FUNCTION FixMul(x, y: Fixed): Fixed;
  31. ; FixMul returns x * y. Note that FixMul effects "type * Fixed --> type":
  32. ; Fixed * Fixed --> Fixed
  33. ; LONGINT * Fixed --> LONGINT
  34. ; Fixed * LONGINT --> LONGINT
  35. ; Fract * Fixed --> Fract
  36. ; Fixed * Fract --> Fract
  37.  
  38. ; FUNCTION FracMul(x, y: Fract): Fract;
  39. ; FracMul returns x * y. Note that FracMul effects "type * Fract --> type":
  40. ; Fract * Fract --> Fract
  41. ; LONGINT * Fract --> LONGINT
  42. ; Fract * LONGINT --> LONGINT
  43. ; Fixed * Fract --> Fixed
  44. ; Fract * Fixed --> Fixed
  45.  
  46. ; FUNCTION FixDiv(x, y: Fixed): Fixed;
  47. ; FixDiv returns x / y. Note that FixDiv effects "type / type --> Fixed":
  48. ; Fixed / Fixed --> Fixed
  49. ; LONGINT / LONGINT --> Fixed
  50. ; Fract / Fract --> Fixed
  51. ; LONGINT / Fixed --> LONGINT
  52. ; Fract / Fixed --> Fract
  53.  
  54. ; FUNCTION FracDiv(x, y: Fract): Fract;
  55. ; FracDiv returns x / y. Note that FracDiv effects "type / type --> Fract":
  56. ; Fract / Fract --> Fract
  57. ; LONGINT / LONGINT --> Fract
  58. ; Fixed / Fixed --> Fract
  59. ; LONGINT / Fract --> LONGINT
  60. ; Fixed / Fract --> Fixed
  61.  
  62. ; FUNCTION FracSqrt(x: Fract): Fract;
  63. ; FracSqrt returns the square root of x. Both argument and result are regarded
  64. ; as unsigned.
  65.  
  66. ; FUNCTION FracCos(x: Fixed): Fract;
  67. ; FUNCTION FracSin(x: Fixed): Fract;
  68. ; FracCos and FracSin return the cosine and sine, respectively, given the
  69. ; argument x in radians.
  70.  
  71. ;The following routines are accessed via the glue code
  72. ;which will call the trap on a 128K ROM machine
  73.  
  74.                 IF            (&TYPE('FixMathNonPortable') = 'UNDEFINED') THEN
  75. FixMathNonPortable EQU        0
  76.                 ENDIF
  77.  
  78.  
  79.                 IF            FixMathNonPortable THEN
  80.  
  81. _FracCos        OPWORD        $A847
  82. _FracSin        OPWORD        $A848
  83. _FracSqrt        OPWORD        $A849
  84. _FracMul        OPWORD        $A84A
  85. _FracDiv        OPWORD        $A84B
  86. _FixDiv         OPWORD        $A84D
  87.  
  88.                 ELSE
  89.  
  90.                 IMPORT        FracMul
  91.                 IMPORT        FracSqrt
  92.                 IMPORT        FracSin
  93.                 IMPORT        FracCos
  94.                 IMPORT        FracDiv
  95.                 IMPORT        FixDiv
  96.  
  97.                 MACRO
  98.                 _FracCos
  99.                 JSR         FracCos
  100.                 ENDM
  101.  
  102.                 MACRO
  103.                 _FracSin
  104.                 JSR         FracSin
  105.                 ENDM
  106.  
  107.                 MACRO
  108.                 _FracSqrt
  109.                 JSR         FracSqrt
  110.                 ENDM
  111.  
  112.                 MACRO
  113.                 _FracMul
  114.                 JSR         FracMul
  115.                 ENDM
  116.  
  117.                 MACRO
  118.                 _FracDiv
  119.                 JSR         FracDiv
  120.                 ENDM
  121.  
  122.                 MACRO
  123.                 _FixDiv
  124.                 JSR         FixDiv
  125.                 ENDM
  126.  
  127.                 ENDIF
  128.